<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;

class VipController extends Controller
{
    // 会员列表
    public function vip_list(){
    	$arr=DB::table('vip')->orderBy('id','desc')->get();
    	return view('/admin/vip/vip_list',['arr'=>$arr]);
    }
    // 会员删除
    public function vip_del(Request $request){
    	if(DB::table('vip')->whereIn('id',$request->ids)->delete()){
    		return 1;
    	}else{
    		return 0;
    	}
    }
    // 会员状态修改
    public function vip_update(Request $request){
    	// return $request->state;
		$state=DB::table('vip')->where('id',$request->id)->value('state');
		   	// return $request->all();
		// return $data;
		if($state==0){
	   		DB::table('vip')->where('id',$request->id)->update(['state'=>1]);
	   		return 1;
		}else{
	   		DB::table('vip')->where('id',$request->id)->update(['state'=>0]);
	   		return 0;
		}
    }
}
